package top.timestreet.xmsk.w23txt.processor;

import org.springframework.stereotype.Component;

import top.timestreet.xmsk.base.pojo.ListPage;
import top.timestreet.xmsk.base.processor.BaseSite;
import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.processor.PageProcessor;
import us.codecraft.webmagic.selector.Html;

/**
* @author TateLiao
* @data 2019年6月3日
* 天籁小说网(www.23txt.com)
* egPage: https://www.23txt.com/files/article/html/44/44114/
*/
@Component
public class W23txtListPageProcessor extends BaseSite implements PageProcessor {

	@Override
	public void process(Page page) {
		Html html = page.getHtml();
		ListPage listPage = new ListPage();
		listPage.setName(html.$("#maininfo #info h1", "text").toString());
		listPage.setAuthor(html.$("#maininfo #info p:nth-child(2)", "text").toString());
		listPage.setLastUpdateTime(html.$("#maininfo #info p:nth-child(4)", "text").toString());
		listPage.setStatus(html.$("#maininfo #info p:nth-child(3)", "text").toString());
		page.putField("listPage", listPage);
	}

	@Override
	public Site getSite() {
		// 天籁小说网编码为gbk
		site.setCharset("gbk");
		return site;
	}

}